package com.dingding.service.common.core.dao.impl;

import java.math.BigDecimal;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.common.core.base.dao.impl.BaseDaoImpl;
import com.dingding.common.core.beans.Useraccount;
import com.dingding.common.core.util.ToolUtil;
import com.dingding.service.common.core.dao.IUserAccountDao;

/**
 * 
 * @ClassName: UserAccountServiceImpl
 * @Description:用户账户Service实现类
 * @author zhaochenguang
 * @date 2015-10-20 上午09:52:25
 * @version 叮叮搭车V2.0
 */
@Component("userAccountDao")
public class UserAccountDaoImpl extends BaseDaoImpl<Useraccount> implements IUserAccountDao {

	/**
	 * 
	 * @Title: addUserAccount 
	 * @Description: 添加用户账户信息 
	 * @param userLoginId 登录id 
	 * @return 
	 * @author CHEHUANBO
	 * 
	 */
	@Transactional(propagation = Propagation.REQUIRED)
	public void addUserAccount(String userLoginId) {

		Useraccount useraccount = new Useraccount();
		// 为用户账户表设置主键
		useraccount.setUaId(ToolUtil.getUid());
		// 用户登录ID
		useraccount.setLoginId(userLoginId);
		// 账户余额
		useraccount.setCurrencyAmount(new BigDecimal(0));
		// 账户状态
		useraccount.setStatus(1);
		// 累计收入
		useraccount.setTotalIncome(new BigDecimal(0));
		// 累计提现
		useraccount.setTotalDeposit(new BigDecimal(0));
		// 累计支出
		useraccount.setTotalExpend(new BigDecimal(0));
		try {
			// 向用户账户表插入一条记录
			super.save(useraccount);
		} catch (Exception e) {
			log.error("添加用户账户信息出现异常！", e);
		}

	}
}
